import tinymce from 'tinymce/tinymce'
import { getStrData2Save } from '@/utils/save'
import { docCheck } from '@/api'
import { Message } from 'element-ui'
import store from '@/store'

tinymce.PluginManager.add('docCheck', function (editor) {
  return (
    editor.ui.registry.addMenuItem('docCheck', {
      text: '检查',
      async onAction() {
        const { data } = await docCheck({ docNo: store.state.xmleditor.editorConfig.docNo, content: getStrData2Save() })
        if (data) {
          Message.success('检查发起成功，请到右侧边栏检查页查看')
        }
      }
    }),
    {
      getMetadata: function () {
        return {
          name: '检查',
          url: 'http://sfrj.cn'
        }
      }
    }
  )
})
